/**
 * 游戏场景中间的路
 * @author zzhanglin
 */
Road = function()
{
	Sprite.call(this);
	this.mouseChildren = false ;
	
	this.topBmp = new Bitmap(ResManager.getInstance().getBmdByName("background-tree"));
	this.topBmp.setShowZone( new Rectangle(0,this.topBmp.getHeight()-GameSetting.SCENE_HEIGHT,this.topBmp.getWidth(),GameSetting.SCENE_HEIGHT) );
	this.bottomBmp = new Bitmap(ResManager.getInstance().getBmdByName("background-tree"));
	this.bottomBmp.setY(this.topBmp.getHeight());
	this.addChild(this.topBmp);
	this.addChild(this.bottomBmp);
	
	this.rect  = new Rectangle(0,0,this.topBmp.getWidth() ,  GameSetting.SCENE_HEIGHT );
	this.rect.y = GameSetting.SCENE_HEIGHT-this.topBmp.getHeight()-this.bottomBmp.getHeight() ; 
	this.setX( (GameSetting.SCENE_WIDTH-this.topBmp.getWidth())>>1 ); //显示在中间
};
FLASH.extend( Road , Sprite);
//Road.prototype=new Sprite(); //继承自Sprite
//Road.prototype.constructor = Road ;

/**
 * 不断更新位置
 * @param speedY
 * @param offsetX
 */
Road.prototype.update = function( speedY , offsetX)
{
	speedY = speedY||0;
	if(this.rect.y<=speedY){
		this.rect.y+=speedY;
	}else{
		this.rect.y = GameSetting.SCENE_HEIGHT-this.getHeight()+speedY*2 ;
	}		
	this.setY( this.rect.y ) ;
};

/**
 * 重写父类的dispose方法
 */
Road.prototype.dispose = function()
{
	Sprite.prototype.dispose.call(this);
	this.rect = null ;
	this.bottomBmp = null ;
	this.topBmp = null ;
};